let header = new Vue({
	el:'#header',
	data:{
		user:{},
		checkLogin:false,
		types:[],
		count:0,
		tno:""
	},
	
	mounted:function(){
		//获取类别
		axios.get("type/list").then(rt => {
			if(rt.status == 200 && rt.data.code == 200){
				this.types = rt.data.data;
				return;
			}
		});
		
		//获取登陆的用户信息
		axios.get("member/info").then(rt => {
			if(rt.status == 200 && rt.data.code == 200){
				this.user = rt.data.data;
				this.checkLogin = true;
				return;
			}
			this.checkLogin = false;
		});
		
		//购物车数据
		this.findCart();
	},
	methods:{
		search: function() {
			let keywords = $.trim($("#keywords").val());
			if(!keywords){
				showmsg("请输入你要搜索的关键字...", "yellow");
				return;
			}
			$.post("goods/find", {keywords: keywords}, rt => {
				if (rt.code == 200){
					app.$data.products = rt.data;
					return;
				}
				app.$data.products = [];
				showmsg("暂无满足条件的数据...", "yellow");
			}, "json");
		},
		findCart:function(){
			axios.get("cart/list").then(rt =>{
			if(rt.status == 200 && rt.data.code == 200){
				this.count = rt.data.data;
				return;
			}
			this.count = 0;
		})
		}
	}
});